/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.nyquistmeteocal.beans;

import it.nyquistmeteocal.entity.Notification;
import it.nyquistmeteocal.boundary.NotificationManager;
import it.nyquistmeteocal.boundary.UserManager;
import it.nyquistmeteocal.entity.UserNotification;
import it.nyquistmeteocal.boundary.UserNotificationManager;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

/**
 *
 * @author gatb27
 */
@Named(value = "tomorrowrainy")
@RequestScoped
public class ListTomorrowRainyBean implements Serializable { 
    
    private static final long serialVersioneUID = 1L;
    
    @EJB
    private NotificationManager nm;
    @EJB
    private UserManager um;
    @EJB
    private UserNotificationManager unm;
    
    private List<Notification> tmrrainyList;
    private UserNotification usernotification = new UserNotification();

    public List<Notification> getTmrrainyList() {
        return tmrrainyList;
    }

    public void setTmrrainyList(List<Notification> tmrrainyList) {
        this.tmrrainyList = tmrrainyList;
    }
    
    @PostConstruct
    public void init() {
        
            tmrrainyList = nm.getTomorrowRainy();
        
    }
    
    public String ReadTmrRainy(Integer notid) {
        Integer unid = nm.findUserNotification(notid);
        usernotification.setId(unid);
        usernotification.setNotificationid(notid);
        String LogUser = um.getLoggedUser().getEmail();
        usernotification.setUsermail(LogUser);
        
        unm.deleteUserNotification(usernotification);
        
        return "showConfirm";
    }
    
    
    
}
